package cn.itcast.javaee.springmvc.app05;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者：13687
 * 日期：2017/3/25
 * 项目：SpringMVC64
 * 描述：View层
 *
 * url 怎么跳转到action 呢？DispatcherServlet-servlet.xml 中配置
 *
 */
public class PracticeAction implements Controller{
	public PracticeAction() {
		System.out.println(this.getClass().getSimpleName() + ":PracticeAction");
	}

	@Override
	public ModelAndView handleRequest(HttpServletRequest httpServletRequest,
	                                  HttpServletResponse httpServletResponse) throws Exception {
		System.out.println(this.getClass().getSimpleName() + ":handleRequest");
//		需要创建 ModeView 对象
		Map<String,String> model=new HashMap<>();
		model.put("message","我是通过ModleAndView对象传递过来的");
		ModelAndView modelAndView = new ModelAndView("success",model);
		return modelAndView;
	}
}
